package bTree.LeetCode;

public class 买卖股票的最佳时机 {
    public int maxProfit(int[] prices) {
        int res=0;
        int has=prices[0];
        for (int price : prices) {
            if (price>has){
                res=Math.max(res,price-has);
            }else {
                has=price;
            }
        }
        return res;
    }
}